home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 050 / madtrb17.arc / DELAY.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1986-02-16  |  2.1 KB  |  63 lines

  1. Program Delay;
  2.  
  3. { PARAMS.PAS by Paul Klarreich, Brooklyn, NY }
  4.  
  5. { Find the parameter string.  In any MS-DOS program file, it is
  6.   found at offset $80 in the program segment prefix -- the first
  7.   $100 bytes of the program segment.  The byte at $80 gives the
  8.   length of the string and the next <length> bytes are the actual
  9.   characters. }
  10.  
  11. { NOTE: This program is meaningless unless compiled to a COM-file or
  12.   the parameter variable is set in the options mode of turbo.        }
  13.  
  14. { Used to create a delay loop by Claire A. Rinehart, Madison, WI. }
  15.  
  16. Type
  17.   Str80 = string[80];
  18.  
  19. Var
  20.   CmdStr: String[80] Absolute CSeg:$0080;   {command string}
  21.   Millisec : integer;        {time variable for delay}
  22.   STime    : string[80];     {string containing the time}
  23.   ErrCode  : integer;
  24.  
  25. Procedure Parse(Var Line : Str80; Var Word : Str80; Delim : Char);
  26. {Removes first word in Line and returns it in Word.  Line is modified so that
  27.  it no longer has leading blanks before the word is filled.  The delim constant
  28.  is used to identify the symbol used to delimit words.  The Line variable is
  29.  decreased in length by one word, and of course leading blanks, before it is
  30.  returned.   Written by Claire A. Rinehart, Madison, WI.                      }
  31. Const
  32.   Space  =  ' ';
  33. Var
  34.   Indx, Len  :  Integer;
  35. Begin
  36.   While Pos(Space, Line) = 1 Do     {remove leading blanks}
  37.     Delete(Line, 1, 1);
  38.   Len := Pos(Delim, Line);
  39.   If Len = 0 then
  40.     begin             {no delimiters left}
  41.       Word := Line;
  42.       Line := '';
  43.     End
  44.   Else If Len = 1 then
  45.       begin                             {check for two delimiters in a row}
  46.         Word := '';                      {return null string}
  47.         Delete(Line, 1, Len);            {delete delimiter}
  48.       End
  49.     Else
  50.       Begin                             {get word and delete from line}
  51.         Word := Copy(Line, 1, Len -1);  {get all but delimiter}
  52.         Delete(Line, 1, Len);            {delete word plus delimeter}
  53.       End
  54. End;  {of Parse}
  55.  
  56.  
  57. Begin
  58.   Parse(CmdStr, STime, ' ');
  59.   Val(STime, Millisec, ErrCode);
  60.   Delay(Millisec);
  61. End.
  62.  
  63.